package io.github.biezhi.elves.model;

import io.github.biezhi.elves.utils.StringUtils;
import lombok.Data;

@Data
public class EbaseInfo {
	//主体身份代码
	private String pripid;
	//企业名称
	private String entname;
	//地市id
	private String regorg;
	//处理regorg字段后的地市id(例如:regorg为440100，处理后的cityId值为4401)
	private String cityId;
	//地市名称
	private String cityName;
	
	public EbaseInfo(){}
	
	public EbaseInfo(String regorg,String cityName){
		this.regorg = formatRegorg(regorg);
		this.cityName = cityName;
	}
	
	public EbaseInfo(String entname){
		this.entname = entname;
	}
	
	public String getCityId() {
		if(StringUtils.isNullOrEmpty(this.regorg)) {
			return "";
		} else {
			return formatRegorg(this.regorg);
		}
	}
	
	/**
	 * 地市格式化
	 * 
	 * 逻辑处理：截取前四位
	 * 例如：440103广州，截取后为4401
	 * @param regorg
	 * @return
	 */
	private String formatRegorg(String regorg) {
		if("440003".equals(regorg)) {
			return "4404";
		}else{
			return regorg.substring(0, 4);
		}
	}
}